/*
 * Copyright (c) 2017-2019, Lindenis Tech. Ltd.
 * All rights reserved.
 *
 * File:
 *
 * Description:
 *
 * Author:
 *      xiaoshujun@lindeni.com
 *
 * Create Date:
 *      2019/08/08
 *
 * History:
 *
 */

#ifndef __DISP_WRAPPER_H_
#define __DISP_WRAPPER_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "osal_types.h"
#include "lindcomponent.h"

typedef long disp_wrapper_t;

typedef enum _aspect_ratio_e
{
    ASPECT_RATIO_DEFAULT            = 0,

    /*
     * Aspect ratio is not kept - the image will be stretched so that it
     * exactly fits the box. (default value).
     */
    ASPECT_RATIO_STRETCH            = ASPECT_RATIO_DEFAULT,

    /*
     * Aspect ratio will be kept, and the image will be scaled down or up
     * so that it fits inside the box, with transparent bars either side
     * if the ratios are not the same.
     * As the mode letterbox or pillarbox.
     */
    ASPECT_RATIO_KEEP,

    /*
     * Aspect ratio is kept, and the image is scaled up so that it fills
     * the box, with any portions that lie outside the box being cropped off.
     * As the mode Pan&Scan.
     */
    ASPECT_RATIO_SCALE,

    /*
     * Aspect ratio is kept, and the image is left unscaled, centered within
     * the box. It may be cropped if the image is larger than the box, or may
     * have a transparent border if the image is smaller than the box.
     */
    ASPECT_RATIO_CENTER,
} aspect_ratio_e;

typedef struct _disp_configs_t
{
    /*
     * source crop in picture
     * if not set, will use the full picture
     */
    rect_t          src_win;

    /*
     * show where on the screen
     * if be set, will not check 'aspect_ratio'
     */
    rect_t          scn_win;

    aspect_ratio_e  aspect_ratio;

    /*
     * range: [0, 16], 0 -> 16, from bottom to up
     */
    int             z_order;

    rotate_degree_e rotate;
} disp_configs_t;

disp_wrapper_t disp_wrapper_create(disp_dev_e disp_id/* not used now */, int channel_id);
int     disp_wrapper_destroy(disp_wrapper_t h_disp);

int     disp_wrapper_set_config(disp_wrapper_t h_disp, disp_configs_t * p_config);
void    disp_wrapper_get_config(disp_wrapper_t h_disp, disp_configs_t * p_config);
int     disp_wrapper_show_frame(disp_wrapper_t h_disp, void * p_picture);
int     disp_wrapper_show_frame2(disp_wrapper_t h_disp, av_frame2_t * p_picture);
int     disp_wrapper_show_black(disp_wrapper_t h_disp);

int     disp_init_reserved_mem(size_t num, size_t size);
void    disp_deinit_reserved_mem();

int     gui_layer_show();
int     gui_layer_hide();

#ifdef __cplusplus
}
#endif

#endif  // __DISP_WRAPPER_H_

